package cn.myplus.blog.controller;

import cn.myplus.blog.configure.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: DevOps 演示Demo
 * @Author libo
 * @Date: 2020/4/14 10:46
 */
@RestController
public class IndexController {

    private final Logger logger = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private Environment environment;

    @Autowired
    private Config config;

    @RequestMapping(value = "/")
    public String index() {

        logger.debug("config:{}", config);

        String env = environment.getProperty("ENV_VALUE");

        StringBuffer buffer = new StringBuffer("hello world. ");
        if (env != null)
            buffer.append(env);
        return buffer.toString();
    }
}
